
#ifndef TYPES_H
#define TYPES_H

#include <string>
#include <functional>
#include <chrono>
#include <memory>

namespace TimeoutManager {

    // 任务状态枚举
    enum class TaskStatus {
        PENDING,    // 等待执行
        RUNNING,    // 正在执行
        COMPLETED,  // 已完成
        CANCELLED,  // 已取消
        TIMEOUT     // 已超时
    };

    // 任务优先级枚举
    enum class Priority {
        LOW = 0,
        NORMAL = 1,
        HIGH = 2,
        URGENT = 3
    };

    // 类型别名定义
    using TaskId = std::string;
    using TimerId = uint64_t;
    using TimePoint = std::chrono::steady_clock::time_point;
    using Duration = std::chrono::milliseconds;
    using Callback = std::function<void()>;

    // 时间工具函数
    inline TimePoint now() {
        return std::chrono::steady_clock::now();
    }

    inline long long currentTimeMs() {
        return std::chrono::duration_cast<std::chrono::milliseconds>(
            now().time_since_epoch()).count();
    }

    // 任务状态转换为字符串
    inline std::string statusToString(TaskStatus status) {
        switch (status) {
            case TaskStatus::PENDING: return "PENDING";
            case TaskStatus::RUNNING: return "RUNNING";
            case TaskStatus::COMPLETED: return "COMPLETED";
            case TaskStatus::CANCELLED: return "CANCELLED";
            case TaskStatus::TIMEOUT: return "TIMEOUT";
            default: return "UNKNOWN";
        }
    }

} // namespace TimeoutManager

#endif // TYPES_H
